package ts;

import java.util.HashMap;

public class Clase {
	public String name;
	public HashMap<String,Metodo> metodos;
	public HashMap<String,Variable> atributos;
	public Constructor constructor; //tiene solo 1
	public boolean declarada;
	public boolean definida;
	public Clase parent;
	public HashMap<String,Metodo> allMetodos; //metodos de la clase y heredados
	public int cirSize; //tamaño del CIR, considerando el +1
	public String etiqueta; //para el cirSize
	
	public Clase() {
		name = null;
		metodos = new HashMap<String,Metodo>();
		allMetodos = new HashMap<String,Metodo>();		
		atributos = new HashMap<String,Variable>();
		//offset = new HashMap<String,Integer>();
		//offset = null;
		constructor = null;
		definida = false;
		declarada = false;
		parent = TablaDeClases.OBJECT;
		cirSize = -1;
	}
	
	public Clase(String n,boolean decl) {
		this();
		name = n;
		etiqueta = "11"+n+"11";
		declarada = decl;
		//parent = TablaDeClases.OBJECT;
		//definida = false;
	}
	
	//Metodo getMetodo(String m) {return null;}
	
	//Variable getAtributo(String a) {return null;}
	
	public void print() {
		System.out.println("*Clase: "+name);
		//System.out.println(name);
		//metodos.print();
		System.out.println("*ATRIBUTOS*");
		for(Variable v:atributos.values()) v.print();
		constructor.print();
		for(Metodo m:metodos.values()) m.print();
		System.out.println("declarada: "+declarada);
		System.out.println("definida: "+definida);
		if (parent!=null) System.out.println("   parent: "+parent.name);
		else System.out.println("   parent: null");
		System.out.println("*allMetodos*");
		for(Metodo m:allMetodos.values()) System.out.println(m.name + " " + m.etiqueta + " " + m.offset);
	}
	
	
	
}
